/* eslint-disable import/prefer-default-export */
import { FILE_URL_PREFIX } from '@/constants';
import request from '@/service/request';
import type { RiskList, RiskMsg } from './types';

// 获取风险浏览列表
export function getRiskList(data: {
  disposalNameList: Array<RiskList>;
  reviewNameList: Array<RiskList>;
  statusList: Array<RiskList>;
  pageNum: number;
  pageSize: number;
  orderColum: string;
  orderType: string;
  inputContent: string;
  myselfId: number;
}) {
  return request.post<RiskList>({
    url: '/rs/getRsVOList',
    data,
    interceptors: {
      responseInterceptor(res: any): any {
        return {
          data: res?.data,
        };
      },
    },
  });
}

// 根据风险id获取风险浏览列表
export function getRiskMsg(rsId: number) {
  return request.get<RiskMsg>({
    url: `/rs/${rsId}`,
    interceptors: {
      responseInterceptor(res: any): any {
        return {
          data: res?.data,
        };
      },
    },
  });
}

// 删除风险浏览列表
export function deleteRiskList(id: number) {
  return request.delete<RiskList>({
    url: `/rs/${id}`,
    interceptors: {
      responseInterceptor(res: any): any {
        return {
          data: res?.data,
        };
      },
    },
  });
}

// 获取用户待办列表
export function getUserToDOList() {
  return request.get<RiskList>({
    url: '/rs/getMyToDOList',
    interceptors: {
      responseInterceptor(res: any): any {
        return {
          data: res.data,
        };
      },
    },
  });
}

// 获取用户待办列表
export function getRiskTemplate(id: number) {
  return request.get<RiskList>({
    url: `/reTemplate/${id}`,
    interceptors: {
      responseInterceptor(res: any): any {
        return {
          data: res.data,
        };
      },
    },
  });
}

// 获取风险浏览列表 指派
export function riskAssign(data: {
  rsAssignDTOs: [
    {
      disposalNameById: number;
      reviewNameById: number;
      id: number;
      disposalScheme: string;
      disposalStopTime: string;
      reviewStopTime: string;
    },
  ];
}) {
  return request.post<RiskList>({
    url: '/rs/rsAssign',
    data,
    interceptors: {
      responseInterceptor(res: any): any {
        return {
          data: res,
        };
      },
    },
  });
}

// 提交处置
export function requestUploadFile(fileData: {
  disposalProof: string; // 文件
  disposalDesc: string;
  id: number;
}) {
  return request.post<string>({
    url: '/rs/checkDisposal',
    data: { id: fileData.id, disposalDesc: fileData.disposalDesc, disposalProof: fileData.disposalProof },
    interceptors: {
      responseInterceptor(res: any): string {
        return FILE_URL_PREFIX + res.code;
      },
    },
  });
}

// 风险审核
export function requestcheckReview(data: {
  disposalId: number;
  disposalStopTime: string;
  id: number;
  reviewOpinion: string;
  reviewResult: number;
}) {
  return request.post<string>({
    url: '/rs/checkReview',
    data,
    interceptors: {
      responseInterceptor(res: any): string {
        return res;
      },
    },
  });
}

// 发送提醒
export function sendRemind(data: { ids: number[] }) {
  return request.post<string>({
    url: '/rs/sendRsReminder',
    data,
    interceptors: {
      responseInterceptor(res: any): string {
        return res;
      },
    },
  });
}

// 发送指派
export function sendrsAssign(data: {
  rsAssignDTOs: {
    disposalNameById: number;
    disposalScheme: string;
    disposalStopTime: string;
    ids: number[];
    reviewNameById: number;
    reviewStopTime: string;
  };
}) {
  return request.post<string>({
    url: '/rs/rsAssign',
    data,
    interceptors: {
      responseInterceptor(res: any): string {
        return res;
      },
    },
  });
}
